package com.lzh.chatnote.webSocket.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum LoginTypeEnum {
    WEIXIN("weixin", 4, "微信登录"),
    QQ("qq", 3, "qq登录"),
    github("github", 2, "github登录"),
    GITEE("gitee", 1, "gitee登录"),
    EMail("email", 0, "邮箱登录");


    public final String type;
    public final Integer value;
    public final String desc;


    private static Map<String, LoginTypeEnum> cache;

    static {
        cache = Arrays.stream(LoginTypeEnum.values())
                .collect(Collectors.toMap(LoginTypeEnum::getType, Function.identity()));
    }

    public static LoginTypeEnum of(String type) {
        return cache.get(type);
    }
}
